import 'package:flutter/material.dart';
import 'package:flutterapp900sui/models/commonIcons.dart';
import 'package:flutterapp900sui/models/listModelItems.dart';

typedef EventHandleBlock = Future Function(int index);

class BusinessListItemCell extends StatelessWidget {

  BusinessListItemCell({
    this.handleBlock,
    this.cellItem
  });

  //  点击回调
  final EventHandleBlock handleBlock;

  final ListCellItem cellItem;

  @override
  Widget build(BuildContext context) {

    var jsonItem = this.cellItem.anyObject;
    var iconPath = jsonItem['ShopImage'];
    var shopName = jsonItem['ShopName'];
    var branchName = jsonItem['BranchName'];
    var commentScore = jsonItem['CommentScore'];
    var bindNames = jsonItem['BindNames'];

    return GestureDetector(
      onTap: _onClick,
      child: Container(
        height: 120,
        child: Container(
          color: Colors.white,
          margin: EdgeInsets.only(left: 10,right: 10),
          child: Row(
            children: [
              Container(
                margin: EdgeInsets.only(left: 10),
                width: 120,
                alignment: Alignment.center,
                child: Image(image: NetworkImage(iconPath),width: 120,height: 90,fit: BoxFit.cover),
              ),
              Expanded(child: Container(
                margin: EdgeInsets.only(left: 10,top: 15,right: 10,bottom: 15),
                child: Column(
                  children: [
                    Container(
                        height: 20,
                        child: Align(
                          alignment: Alignment.centerLeft,
                          child: Text(shopName,style: TextStyle(
                            fontSize: 16
                          ),),
                        )
                    ),
                    Expanded(child: Container(
                      child: Row(
                        children: [
                          Container(
                            child: Text('0.0分', style: TextStyle(
                              color: Color(0XFFFA9E55),
                                fontWeight: FontWeight.bold
                            ),),
                          ),
                          Container(
                            margin: EdgeInsets.only(left: 5),
                            child: Text('美容，美发，中医养生，SPA',style: TextStyle(
                              color: Color(0XFF707070)
                            ),),
                          ),
                        ],
                      ),
                    ),),
                    Container(
                        height: 20,
                        child: Align(
                          alignment: Alignment.centerLeft,
                          child: Text('宝山区/宝山城区',style: TextStyle(
                            color: Color(0XFF707070)
                          ),),
                        )
                    )
                  ],
                ),
              )),
              Container(
                margin: EdgeInsets.only(bottom: 15),
                width: 30,
                child: Align(
                  alignment: Alignment.bottomCenter,
                  child: Icon(CommonIcons.qrCode, color: Colors.red,size:20,),
                ),
              ),
            ],
          ),
        ),
      )
    );
  }

  //  点击事件
  void _onClick(){
    handleBlock(1);
  }
}